package com.example.myapplication;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    MyHelper myHelper;
    private EditText mEtNama;
    private EditText mEtPhone;
    private TextView mTvShow;
    private Button mBtnAdd;
    private Button mBtnQuery;
    private Button mBtnUpdeta;
    private Button mBtnDelete;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        myHelper= new MyHelper(this);
        init();
    }

    private void init() {
        mEtNama=(EditText)findViewById(R.id.et_name);
        mEtPhone=(EditText)findViewById(R.id.et_phone);
        mTvShow=(TextView)findViewById(R.id.tv_show);
        mBtnAdd=(Button)findViewById(R.id.btn_add);
        mBtnQuery=(Button)findViewById(R.id.btn_query);
        mBtnUpdeta=(Button)findViewById(R.id.btn_updata);
        mBtnDelete=(Button)findViewById(R.id.btn_delete);
        mBtnAdd.setOnClickListener(this);
        mBtnQuery.setOnClickListener(this);
        mBtnUpdeta.setOnClickListener(this);
        mBtnDelete.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        String name;
        String phone;
        SQLiteDatabase  db;
        ContentValues values;
        switch (v.getId()){
            case R.id.btn_add://添加数据
                name=mEtNama.getText().toString();
                phone=mEtPhone.getText().toString();
                db=myHelper.g
        }
    }

    class MyHeeler extends SQLiteOpenHelper {
        public MyHeeler(Context context){
            super   (context,"itcast.db",null,1);

        }
        @Override
        public void onCreate(SQLiteDatabase db) {
            db.execSQL("CREATE TABLE information(_id INTEGER PRIMARY KEY AUTOINCREMENT,name VARCHAR(20),phone VARCHAR(20))");
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

        }
    }


    private class MyHelper {
        public MyHelper(MainActivity mainActivity) {
        }
    }
}
